package com.edushare.common.vo;

import java.util.Date;

import com.edushare.common.vo.auto._UserAssignmentLink;

public class UserAssignmentLink extends _UserAssignmentLink implements
	DateComparision {

	private static final long serialVersionUID = -6562962604979594397L;

	public static final Integer ASSIGNEE 					= 10;
	public static final Integer ASSIGNER 					= 20;

	public static final int STATUS_SUBMISSION_PENDING 		= 10;
	public static final int STATUS_SUBMISSION_DONE 			= 20;
	public static final int STATUS_SUBMISSION_LATE 			= 30;
	public static final int STATUS_SUBMISSION_NONE 			= 40;

	public static final Integer FILTER_NONE 				= 0;
	public static final Integer FILTER_SUBMISSIONS 			= 10;
	public static final Integer FILTER_INTIME 				= 20;
	public static final Integer FILTER_LATE 				= 30;
	public static final Integer FILTER_PENDING 				= 40;
	public static final Integer FILTER_DEFAULTED 			= 50;

	public static final Integer EVALUATED 					= 10;
	public static final Integer NOT_EVALUATED 				= 20;

	public static final Integer ALERT_DONT_SHOW 			= 0;
	public static final Integer ALERT_SHOW		 			= 10;

	public int getSubmissionStatus(Assignments assignment) {
		if (assignment.getStatus() == Assignments.ASSIGNMENT_STATUS_OPEN) {
			return STATUS_SUBMISSION_DONE;
		} else if (assignment.getStatus() == Assignments.ASSIGNMENT_STATUS_LATE) {
			return STATUS_SUBMISSION_LATE;
		} else if (assignment.getStatus() == Assignments.ASSIGNMENT_STATUS_CLOSED) {
			return STATUS_SUBMISSION_NONE;
		} else {
			return STATUS_SUBMISSION_PENDING;
		}
	}

	public String getStatusAsString() {
		System.out.println("THIS: " + this + "\n");
		if (getStatus() == STATUS_SUBMISSION_PENDING) {
			return "Submission Pending";
		} else if (getStatus() == STATUS_SUBMISSION_DONE) {
			return "In-time Submission";
		} else if (getStatus() == STATUS_SUBMISSION_LATE) {
			return "Late Submission";
		} else if (getStatus() == STATUS_SUBMISSION_NONE) {
			return "No Submission";
		} else {
			return "Not Available";
		}
	}

	public int compareTo(IDateComparable arg0) {
		if(getDate().getTime() < arg0.getDate().getTime())
			return -1;
		else if(arg0.getDate().getTime() == getDate().getTime())
			return 0;
		else
			return 1;
	}

	public Date getDate() {
		if(getAssignment().getAllowLate() == Assignments.ASSIGNMENT_ALLOW_LATE_SUBMIT)
			return getAssignment().getLateSubmDate();
		return getAssignment().getEndDate();
	}

}
